package interpreter.example;

/**
 * @author cheng:
 * @date 2019/4/26 14:39
 */
public class Test {
    public static void main(String[] args) {
        PlayContext context = new PlayContext();
        System.out.println("上海滩：");
        context.setText("T 500 O 2 E 0.5 G 0.5 A 3 E 0.5 G 0.5 D 3 E 0.5 G 0.5 A 0.5 O 3 C 1 O 2 A 0.5 G 1 C 0.5 E 0.5 D 3 ");
        Expression expression;
        try {
            while (context.getText().length() > 0){
                String str = context.getText().substring(0, 1);

                expression = TerminalFactory.createExpression(str);

                if(expression != null){
                    expression.interpret(context);
                }
            }
        }catch (Exception e){
            System.out.println(e.getMessage());
        }
    }
}
